
#include "Mapper240.h"

SETUP_STATIC_INES_MAPPER_REGISTRAR(240)

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
Mapper240::Mapper240() {

	set_prg_89ab(0);
	set_prg_cdef(-1);

	// should have chr-rom
	set_chr_0000_1fff(0);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
std::string Mapper240::name() const {
	return "iNES #240";
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper240::write_4(uint16_t address, uint8_t value) {

	if(address > 0x4020) {
		write_handler(address, value);
	} else {
		Mapper::write_4(address, value);
	}
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper240::write_5(uint16_t address, uint8_t value) {
	write_handler(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper240::write_handler(uint16_t address, uint8_t value) {
	(void)address;
	set_prg_89abcdef(value >> 4);
	set_chr_0000_1fff(value & 0x0f);
}
